package com.yao.component.circle;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.util.AttributeSet;
import android.widget.RelativeLayout;

import com.yao.component.circle.dataobject.Post;

/**
 * Created by Administrator on 2015/10/26.
 */
public class MessageView extends RelativeLayout {


    private RecyclerView recyclerView;
    private MessageAdapter messageAdapter;
    private com.yao.sdk.widget.ExtLinearLayoutManager layoutManager;
    private CircleView circleView;


    public MessageView(Context context, AttributeSet attrs) {
        super(context, attrs);
        init(context);
    }

    private void init(Context context) {
        /*LayoutInflater inflater=(LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        View view = inflater.inflate(R.layout.comment_view, null);*/
        initRecyclerView(context);
    }

    private void initRecyclerView(Context context) {
        // use a linear item_circle manager
        recyclerView = new RecyclerView(context);
       // recyclerView = (RecyclerView) view.findViewById(R.id.comment_list);
        layoutManager = new com.yao.sdk.widget.ExtLinearLayoutManager(context);
        messageAdapter = new MessageAdapter();
        recyclerView.setLayoutManager(layoutManager);
        recyclerView.setAdapter(messageAdapter);
        addView(recyclerView);
    }

    public void setCircleView(CircleView circleView) {
        this.circleView = circleView;


        messageAdapter.setCircleView(this.circleView);
    }

    public void refreshData(Post post) {
        messageAdapter.setData(post);
        messageAdapter.notifyDataSetChanged();
    }

}
